/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package roomarrange;

import com.sun.data.provider.RowKey;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.sql.rowset.CachedRowSetXImpl;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.Checkbox;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableRowGroup;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.convert.BooleanConverter;
import javax.faces.convert.IntegerConverter;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.spi.SyncProviderException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @version admin.java
 * @version Created on 2009-8-25, 13:36:49
 * @author ben
 */
public class admin extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        t_usrsetDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_usrsetRowSet}"));
        t_grpsetDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_grpsetRowSet}"));
        t_roomsetDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsetRowSet}"));
        t_grpsortDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_grpsortRowSet}"));
        t_grpusrsDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_grpusrsRowSet}"));
        v_grpusrsDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.v_grpusrsRowSet}"));
        t_roomsetDataProvider1.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsetRowSet}"));
        t_roomsortDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsortRowSet}"));
        t_meetingsDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_meetingsRowSet}"));
        t_roomsetDataProvider2.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsetRowSet}"));
        t_roomsetDataProvider3.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsetRowSet_wrkspc4}"));
        t_roomsortDataProvider1.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.t_roomsortRowSet}"));
    }
    private CachedRowSetDataProvider t_usrsetDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_usrsetDataProvider() {
        return t_usrsetDataProvider;
    }

    public void setT_usrsetDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_usrsetDataProvider = crsdp;
    }
    private Table table1 = new Table();

    public Table getTable1() {
        return table1;
    }

    public void setTable1(Table t) {
        this.table1 = t;
    }
    private TableRowGroup tableRowGroup1 = new TableRowGroup();

    /**
     * @return the tableRowGroup1
     */
    public TableRowGroup getTableRowGroup1() {
        return tableRowGroup1;
    }

    /**
     * @param tableRowGroup1 the tableRowGroup1 to set
     */
    public void setTableRowGroup1(TableRowGroup tableRowGroup1) {
        this.tableRowGroup1 = tableRowGroup1;
    }
    private TableRowGroup tableRowGroup2 = new TableRowGroup();

    public TableRowGroup getTableRowGroup2() {
        return tableRowGroup2;
    }

    public void setTableRowGroup2(TableRowGroup trg) {
        this.tableRowGroup2 = trg;
    }
    private CachedRowSetDataProvider t_grpsetDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_grpsetDataProvider() {
        return t_grpsetDataProvider;
    }

    public void setT_grpsetDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_grpsetDataProvider = crsdp;
    }
    private CachedRowSetDataProvider t_roomsetDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsetDataProvider() {
        return t_roomsetDataProvider;
    }

    public void setT_roomsetDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_roomsetDataProvider = crsdp;
    }
    private CachedRowSetDataProvider t_grpsortDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_grpsortDataProvider() {
        return t_grpsortDataProvider;
    }

    public void setT_grpsortDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_grpsortDataProvider = crsdp;
    }
    private IntegerConverter dropDown1Converter = new IntegerConverter();

    public IntegerConverter getDropDown1Converter() {
        return dropDown1Converter;
    }

    public void setDropDown1Converter(IntegerConverter ic) {
        this.dropDown1Converter = ic;
    }
    private DropDown dropDown2 = new DropDown();

    public DropDown getDropDown2() {
        return dropDown2;
    }

    public void setDropDown2(DropDown dd) {
        this.dropDown2 = dd;
    }
    private IntegerConverter dropDown2Converter = new IntegerConverter();

    public IntegerConverter getDropDown2Converter() {
        return dropDown2Converter;
    }

    public void setDropDown2Converter(IntegerConverter ic) {
        this.dropDown2Converter = ic;
    }
    private CachedRowSetDataProvider t_grpusrsDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_grpusrsDataProvider() {
        return t_grpusrsDataProvider;
    }

    public void setT_grpusrsDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_grpusrsDataProvider = crsdp;
    }
    private CachedRowSetDataProvider v_grpusrsDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getV_grpusrsDataProvider() {
        return v_grpusrsDataProvider;
    }

    public void setV_grpusrsDataProvider(CachedRowSetDataProvider crsdp) {
        this.v_grpusrsDataProvider = crsdp;
    }
    private TableRowGroup tableRowGroup3 = new TableRowGroup();

    public TableRowGroup getTableRowGroup3() {
        return tableRowGroup3;
    }

    public void setTableRowGroup3(TableRowGroup trg) {
        this.tableRowGroup3 = trg;
    }
    private IntegerConverter dropDown3Converter = new IntegerConverter();

    public IntegerConverter getDropDown3Converter() {
        return dropDown3Converter;
    }

    public void setDropDown3Converter(IntegerConverter ic) {
        this.dropDown3Converter = ic;
    }
    private IntegerConverter dropDown4Converter = new IntegerConverter();

    public IntegerConverter getDropDown4Converter() {
        return dropDown4Converter;
    }

    public void setDropDown4Converter(IntegerConverter ic) {
        this.dropDown4Converter = ic;
    }
    private IntegerConverter integerConverter2 = new IntegerConverter();

    public IntegerConverter getIntegerConverter2() {
        return integerConverter2;
    }

    public void setIntegerConverter2(IntegerConverter ic) {
        this.integerConverter2 = ic;
    }
    private IntegerConverter integerConverter3 = new IntegerConverter();

    public IntegerConverter getIntegerConverter3() {
        return integerConverter3;
    }

    public void setIntegerConverter3(IntegerConverter ic) {
        this.integerConverter3 = ic;
    }
    private BooleanConverter booleanConverter1 = new BooleanConverter();

    public BooleanConverter getBooleanConverter1() {
        return booleanConverter1;
    }

    public void setBooleanConverter1(BooleanConverter bc) {
        this.booleanConverter1 = bc;
    }
    private IntegerConverter integerConverter4 = new IntegerConverter();

    public IntegerConverter getIntegerConverter4() {
        return integerConverter4;
    }

    public void setIntegerConverter4(IntegerConverter ic) {
        this.integerConverter4 = ic;
    }
    private IntegerConverter integerConverter5 = new IntegerConverter();

    public IntegerConverter getIntegerConverter5() {
        return integerConverter5;
    }

    public void setIntegerConverter5(IntegerConverter ic) {
        this.integerConverter5 = ic;
    }
    private DropDown dropDown3 = new DropDown();

    public DropDown getDropDown3() {
        return dropDown3;
    }

    public void setDropDown3(DropDown dd) {
        this.dropDown3 = dd;
    }
    private Checkbox checkbox1 = new Checkbox();

    public Checkbox getCheckbox1() {
        return checkbox1;
    }

    public void setCheckbox1(Checkbox c) {
        this.checkbox1 = c;
    }
    private CachedRowSetDataProvider t_roomsetDataProvider1 = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsetDataProvider1() {
        return t_roomsetDataProvider1;
    }

    public void setT_roomsetDataProvider1(CachedRowSetDataProvider crsdp) {
        this.t_roomsetDataProvider1 = crsdp;
    }
    private TableRowGroup tableRowGroup4 = new TableRowGroup();

    public TableRowGroup getTableRowGroup4() {
        return tableRowGroup4;
    }

    public void setTableRowGroup4(TableRowGroup trg) {
        this.tableRowGroup4 = trg;
    }
    private IntegerConverter dropDown5Converter = new IntegerConverter();

    public IntegerConverter getDropDown5Converter() {
        return dropDown5Converter;
    }

    public void setDropDown5Converter(IntegerConverter ic) {
        this.dropDown5Converter = ic;
    }
    private CachedRowSetDataProvider t_roomsortDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsortDataProvider() {
        return t_roomsortDataProvider;
    }

    public void setT_roomsortDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_roomsortDataProvider = crsdp;
    }
    private IntegerConverter dropDown6Converter = new IntegerConverter();

    public IntegerConverter getDropDown6Converter() {
        return dropDown6Converter;
    }

    public void setDropDown6Converter(IntegerConverter ic) {
        this.dropDown6Converter = ic;
    }
    private TableRowGroup tableRowGroup5 = new TableRowGroup();

    public TableRowGroup getTableRowGroup5() {
        return tableRowGroup5;
    }

    public void setTableRowGroup5(TableRowGroup trg) {
        this.tableRowGroup5 = trg;
    }
    private CachedRowSetDataProvider t_meetingsDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_meetingsDataProvider() {
        return t_meetingsDataProvider;
    }

    public void setT_meetingsDataProvider(CachedRowSetDataProvider crsdp) {
        this.t_meetingsDataProvider = crsdp;
    }
    private DropDown dropDown7 = new DropDown();

    public DropDown getDropDown7() {
        return dropDown7;
    }

    public void setDropDown7(DropDown dd) {
        this.dropDown7 = dd;
    }
    private Calendar calendar2 = new Calendar();

    public Calendar getCalendar2() {
        return calendar2;
    }

    public void setCalendar2(Calendar c) {
        this.calendar2 = c;
    }
    private Calendar calendar1 = new Calendar();

    public Calendar getCalendar1() {
        return calendar1;
    }

    public void setCalendar1(Calendar c) {
        this.calendar1 = c;
    }
    private CachedRowSetDataProvider t_roomsetDataProvider2 = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsetDataProvider2() {
        return t_roomsetDataProvider2;
    }

    public void setT_roomsetDataProvider2(CachedRowSetDataProvider crsdp) {
        this.t_roomsetDataProvider2 = crsdp;
    }
    private IntegerConverter dropDown7Converter = new IntegerConverter();

    public IntegerConverter getDropDown7Converter() {
        return dropDown7Converter;
    }

    public void setDropDown7Converter(IntegerConverter ic) {
        this.dropDown7Converter = ic;
    }
    private TableRowGroup tableRowGroup6 = new TableRowGroup();

    public TableRowGroup getTableRowGroup6() {
        return tableRowGroup6;
    }

    public void setTableRowGroup6(TableRowGroup trg) {
        this.tableRowGroup6 = trg;
    }
    private CachedRowSetDataProvider t_roomsetDataProvider3 = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsetDataProvider3() {
        return t_roomsetDataProvider3;
    }

    public void setT_roomsetDataProvider3(CachedRowSetDataProvider crsdp) {
        this.t_roomsetDataProvider3 = crsdp;
    }
    private CachedRowSetDataProvider t_roomsortDataProvider1 = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getT_roomsortDataProvider1() {
        return t_roomsortDataProvider1;
    }

    public void setT_roomsortDataProvider1(CachedRowSetDataProvider crsdp) {
        this.t_roomsortDataProvider1 = crsdp;
    }
    private IntegerConverter dropDown8Converter = new IntegerConverter();

    public IntegerConverter getDropDown8Converter() {
        return dropDown8Converter;
    }

    public void setDropDown8Converter(IntegerConverter ic) {
        this.dropDown8Converter = ic;
    }


    // </editor-fold>
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public admin() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("admin Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

    // </editor-fold>
    // Perform application initialization that must complete
    // *after* managed components are initialized
    // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
        if (null != this.getDropDown2().getSelected()) {
            return;
        }
        CachedRowSet crs1 = this.getSessionBean1().getT_grpsetRowSet();
        this.getT_grpsetDataProvider().setCachedRowSet(crs1);
        this.getT_grpsetDataProvider().cursorFirst();
        Object grpId = this.getT_grpsetDataProvider().getValue("i_id");
        this.getDropDown2().setSelected(grpId);

        try {
            CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
            crs.setObject(1, grpId);
            crs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(admin.class.getName()).log(Level.SEVERE, null, ex);
        }
           //一个不存在的条件，为了不刷新出内容
            Object mtId = 0;
            Object sdate = "2109-10-01";
            Object edate = "2109-10-01";

            try {
                CachedRowSet crs = this.getSessionBean1().getT_meetingsRowSet();
                crs.setObject(1, mtId);
                crs.setObject(2, sdate);
                crs.setObject(3, edate);
                crs.execute();
            } catch (SQLException ex) {
                Logger.getLogger(admin.class.getName()).log(Level.SEVERE, null, ex);
            }

    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
        t_usrsetDataProvider.close();
        t_grpsetDataProvider.close();
        t_roomsetDataProvider.close();
        t_grpsortDataProvider.close();
        t_grpusrsDataProvider.close();
        v_grpusrsDataProvider.close();
        t_roomsetDataProvider1.close();
        t_roomsortDataProvider.close();
        t_meetingsDataProvider.close();
        t_roomsetDataProvider2.close();
        t_roomsetDataProvider3.close();
        t_roomsortDataProvider1.close();
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    public String button1_action() throws SyncProviderException, SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //人员－增加
        CachedRowSet crs = this.getSessionBean1().getT_usrsetRowSet();
        crs.moveToInsertRow();
        crs.insertRow();

        return null;
    }

    public String button4_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //人员－删除
        int li_rk;
        CachedRowSet crs = this.getSessionBean1().getT_usrsetRowSet();
        CachedRowSetXImpl usrRs;
        RowKey rk = this.getTableRowGroup1().getRowKey();
        li_rk = Integer.parseInt(rk.getRowId()) + 1;
        crs.absolute(li_rk);
        crs.deleteRow();
        crs.acceptChanges();
        crs.commit();


        //crs.execute();
        return null;
    }

    public String button3_action() throws SQLException {
        // TODO: Replace with your code
        //人员－刷新
        CachedRowSet crs = this.getSessionBean1().getT_usrsetRowSet();
        crs.execute();
        return null;
    }

    public String button2_action() throws SyncProviderException, SQLException {
        // TODO: Replace with your code
        //人员－保存
        CachedRowSet crs = this.getSessionBean1().getT_usrsetRowSet();
        crs.acceptChanges();
        crs.commit();
        crs.execute();
        // crs.close();

        return null;
    }

    public String button5_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组－增加
        CachedRowSet crs = this.getSessionBean1().getT_grpsetRowSet();
        crs.moveToInsertRow();
        crs.insertRow();

        return null;
    }

    public String button6_action() throws SyncProviderException, SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组－保存
        CachedRowSet crs = this.getSessionBean1().getT_grpsetRowSet();
        crs.acceptChanges();
        crs.commit();
        crs.execute();

        return null;
    }

    public String button7_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组－刷新
        CachedRowSet crs = this.getSessionBean1().getT_grpsetRowSet();
        crs.execute();

        return null;
    }

    public String button8_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组－删除
        int li_rk;
        CachedRowSet crs = this.getSessionBean1().getT_grpsetRowSet();
        RowKey rk = this.getTableRowGroup2().getRowKey();
        li_rk = Integer.parseInt(rk.getRowId()) + 1;
        crs.absolute(li_rk);
        crs.deleteRow();
        crs.acceptChanges();
        crs.commit();

        return null;
    }

    public void dropDown2_processValueChange(ValueChangeEvent event) throws SQLException {
        Object grpId = event.getNewValue();
        CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
        crs.setObject(1, grpId);
        crs.execute();

    }

    public String tab3_action() {
        // TODO: Replace with your code
        return null;
    }

    public String tab2_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public String button9_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组用户－删除
        int li_rk, li_grpid, li_usrid;
        CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
        RowKey rk = this.getTableRowGroup3().getRowKey();
        li_rk = Integer.parseInt(rk.getRowId()) + 1;
        crs.absolute(li_rk);
        li_usrid = crs.getInt("usr_id");
        li_grpid = crs.getInt("grp_id");
 
         CachedRowSetXImpl usrRs;
        //从数据库中取值验证
        String ls_conn = this.getApplicationBean1().getGs_conn();
        usrRs = new CachedRowSetXImpl();
        usrRs.setDataSourceName(ls_conn);
        usrRs.setCommand("select igrpid,iusrid from t_grpusrs where igrpid = ? and iusrid = ? ");
        usrRs.setTableName("t_grpusrs");
        usrRs.setInt(1, li_grpid);
        usrRs.setInt(2,li_usrid);
        usrRs.execute();
        if (usrRs.size()>0){
            usrRs.first();
            usrRs.deleteRow();
            usrRs.acceptChanges();
            usrRs.commit();
            crs.execute();
        }


        return null;
    }

    public String button10_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组用户－增加
        Object li_grpid, li_usrid, li_isleader;
        li_grpid = this.getDropDown2().getValue();
        li_usrid = this.getDropDown3().getValue();
        li_isleader = this.getCheckbox1().getValue();
        if (li_isleader == null) {
            li_isleader = 0;
        }
         CachedRowSetXImpl usrRs;
        //从数据库中取值验证
        String ls_conn = this.getApplicationBean1().getGs_conn();
        usrRs = new CachedRowSetXImpl();
        usrRs.setDataSourceName(ls_conn);
        usrRs.setCommand("select igrpid,iusrid from t_grpusrs where igrpid = ? and iusrid = ? ");
        usrRs.setTableName("t_grpusrs");
        usrRs.setObject(1, li_grpid);
        usrRs.setObject(2,li_usrid);
        usrRs.execute();
        if (usrRs.size()>0){
            usrRs.first();
            usrRs.deleteRow();
            usrRs.acceptChanges();
            usrRs.commit();
        }


        CachedRowSet crs1 = this.getSessionBean1().getT_grpusrsRowSet();
        crs1.execute();
        crs1.moveToInsertRow();
        crs1.updateObject("igrpid", li_grpid);
        crs1.updateObject("iusrid", li_usrid);
        crs1.updateObject("ileader", li_isleader);
        crs1.insertRow();
        crs1.acceptChanges();

        CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
        crs.execute();

        return null;
    }

    public String button11_action() throws SyncProviderException, SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组用户－ 保存
        CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
        crs.acceptChanges();
        crs.commit();
        crs.execute();

        return null;
    }

    public String button12_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //群组用户－刷新
        CachedRowSet crs = this.getSessionBean1().getV_grpusrsRowSet();
        crs.execute();

        return null;
    }

    public String button13_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //会议室－增加
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet();
        crs.moveToInsertRow();
        crs.insertRow();

        return null;
    }

    public String button14_action() throws SyncProviderException, SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //会议室－保存
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet();
        crs.acceptChanges();
        crs.commit();
        crs.execute();

        return null;
    }

    public String button15_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //会议室－刷新
          CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet();
          crs.execute();
      
        return null;
    }

    public String button16_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //工作区－删除
       int li_rk;
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet();
        RowKey rk = this.getTableRowGroup4().getRowKey();
        li_rk = Integer.parseInt(rk.getRowId()) + 1;
        crs.absolute(li_rk);
        crs.deleteRow();
        crs.acceptChanges();
        crs.commit();

        return null;
    }

    public String tab5_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        HttpSession hs;
        hs = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
        if(hs!=null){
            hs.invalidate();
            return "toLogin";
        }
        return null;
    }

    public String button17_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        if (this.getDropDown7().getSelected() == null) {
            info("请选择会议室");
            return null;
        }

        if (this.getCalendar1().getValue() == null) {
            info("请选择开始日期");
            return null;
        }
        if (this.getCalendar2().getValue() == null) {
            info("请选择截止日期");
            return null;
        }
        String ls_sdate = "";
        String ls_edate = "";
        int li_roomid=0;
        Date ld_sdate = null;
        Date ld_edate = null;
        ld_sdate = (Date) this.getCalendar1().getValue();
        ld_edate = (Date) this.getCalendar2().getValue();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        ls_sdate = sdf.format(ld_sdate);
        ls_edate = sdf.format(ld_edate);

        try {

            CachedRowSet crs = this.getSessionBean1().getT_meetingsRowSet();
            crs.setObject(1, this.getDropDown7().getSelected());
            crs.setObject(2, ls_sdate);
            crs.setObject(3, ls_edate);
            crs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(admin.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }

    public String button18_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        String ls_meetingid = "";

        int li_status = 0;
        int li_roomid = 0;
        Date ldt_sdate;
        Date ldt_now;
        long ll_s;
        long ll_now;

        CachedRowSet crs;
        try {
            crs = this.getSessionBean1().getT_meetingsRowSet();
            RowKey rk = this.getTableRowGroup5().getRowKey();
            int li_rk = Integer.parseInt(rk.getRowId()) + 1;
            crs.absolute(li_rk);
            ls_meetingid = crs.getString("i_id");

        //crs.deleteRow();
        } catch (SQLException ex) {
            Logger.getLogger(admin.class.getName()).log(Level.SEVERE, null, ex);
        }


        //生成临时数据
        ApplicationContext ctx = new ClassPathXmlApplicationContext("SpringConfig.xml");
        DataSource ds = (DataSource) ctx.getBean("dataSourceDBDirect");
        //DataSource ds = (DataSource) ctx.getBean("dataSourcePool");
        DataJdbcDao taskDao = new DataJdbcDao();
        taskDao.setDataSource(ds);
        //首先获取会议的信息
        meetings mt = new meetings();
        String sapp = this.getSessionBean1().getSApp();
        mt = taskDao.getMeeting(ls_meetingid,sapp);
        li_status = mt.getIStatus();
        li_roomid = mt.getIRoomid();
        ldt_sdate = mt.getDSdate();
       //发送qq信息
        ldt_now = new Date();
        ll_s = ldt_sdate.getTime();
        ll_now = ldt_now.getTime();
        if (ll_s > ll_now) {
            //只有该会议尚未开始才发送qq消息
            int ibj = -1;
            setupParam stp = new setupParam();
            stp = taskDao.getParam();
            taskDao.sendRTX(mt, ibj,stp);
        }

        //删除会议
        taskDao.removeMeeting(ls_meetingid,sapp);

        //刷新列表
        Date ld_sdate = (Date) this.getCalendar1().getValue();
        Date ld_edate = (Date) this.getCalendar2().getValue();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String ls_sdate = sdf.format(ld_sdate);
        String ls_edate = sdf.format(ld_edate);
        int li_usrid = this.getSessionBean1().getIusrid();
        try {

            crs = this.getSessionBean1().getT_meetingsRowSet();
            crs.setObject(1, li_roomid);
            crs.setObject(2, ls_sdate);
            crs.setObject(3, ls_edate);
            crs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(admin.class.getName()).log(Level.SEVERE, null, ex);
        }
        info("会议记录删除成功！");

        return null;
    }

    public String button19_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //工作区删除
       int li_rk;
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet_wrkspc4();
        RowKey rk = this.getTableRowGroup6().getRowKey();
        li_rk = Integer.parseInt(rk.getRowId()) + 1;
        crs.absolute(li_rk);
        crs.deleteRow();
        crs.acceptChanges();
        crs.commit();

        return null;
    }

    public String button21_action() throws SyncProviderException, SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //工作区-保存
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet_wrkspc4();
        crs.acceptChanges();
        crs.commit();
        crs.execute();

        return null;
    }

    public String button20_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //工作区-增加
        CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet_wrkspc4();
        crs.moveToInsertRow();
        crs.insertRow();

        return null;
    }

    public String button22_action() throws SQLException {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //工作区-刷新
      CachedRowSet crs = this.getSessionBean1().getT_roomsetRowSet_wrkspc4();
      crs.execute();

        return null;
    }


}

